Moved Gdk test functions from Gtk+ to Gdk test utils.
authorTim Janik <timj@src.gnome.org>
Tue, 20 Nov 2007 15:03:31 +0000 (15:03 +0000)
committerTim Janik <timj@src.gnome.org>
Tue, 20 Nov 2007 15:03:31 +0000 (15:03 +0000)
* gdk/Makefile.am: added gdktestutils.h to public includes.

* gdk/gdk.h: added gdktestutils.h to public includes.

* gdk/gdk.symbols: added gdk_test_simulate_button, gdk_test_simulate_key,
gdk_test_render_sync.

* gdk/gdktestutils.h: new file, added prototypes for gdk_test_simulate_button,
gdk_test_simulate_key, gdk_test_render_sync.

* gdk/x11/Makefile.am: build gdktestutils-x11.c.

* gdk/x11/gdktestutils-x11.c: implemented gdk_test_simulate_button,
gdk_test_simulate_key, gdk_test_render_sync.

* gtk/gtktestutils.c:
* gtk/gtktestutils.h:
* gtk/gtk.symbols: removed gtk_test_simulate_button
gtk_test_simulate_key, gtk_test_xserver_render_sync.

* gtk/tests/testing.c: call gdk_test_render_sync.

svn path=/trunk/; revision=19012

gdk/Makefile.am
gdk/gdk.h
gdk/gdk.symbols
gdk/gdktestutils.h [new file with mode: 0644]
gdk/x11/Makefile.am
gdk/x11/gdktestutils-x11.c [new file with mode: 0644]
gtk/gtk.symbols
gtk/gtktestutils.c
gtk/gtktestutils.h
gtk/tests/testing.c

index e22c318273e9514d6094b3f1a974582d67eb1488..5c5f97daad218e2f5896ea2e87c2d718db15e374 100644 (file)
@@ -85,6 +85,7 @@ gdk_public_h_sources =                                \
        gdkscreen.h                             \
        gdkselection.h                          \
        gdkspawn.h                              \
+       gdktestutils.h                          \
        gdktypes.h                              \
        gdkvisual.h                             \
        gdkwindow.h
index d84d304a742ed0d2a6178d75fe016bfa7960912b..7f6fc2335863186b9b23fb75b81f42393b7f45c7 100644 (file)
--- a/gdk/gdk.h
+++ b/gdk/gdk.h
@@ -50,6 +50,7 @@
 #include <gdk/gdkscreen.h>
 #include <gdk/gdkselection.h>
 #include <gdk/gdkspawn.h>
+#include <gdk/gdktestutils.h>
 #include <gdk/gdktypes.h>
 #include <gdk/gdkvisual.h>
 #include <gdk/gdkwindow.h>
index d7962109fe622da9e4c5eae51c89331a8c8fe05a..a92e7e9413780e6e7206233c99d0c20f8750c619 100644 (file)
@@ -27,6 +27,14 @@ gdk_events_pending
 #endif
 #endif
 
+#if IN_HEADER(__GDK_TEST_UTILS_H__)
+#if IN_FILE(__GDK_TEST_UTILS_X11_C__)
+gdk_test_simulate_button
+gdk_test_simulate_key
+gdk_test_render_sync
+#endif
+#endif
+
 #if IN_HEADER(__GDK_EVENTS_H__)
 #if IN_FILE(__GDK_EVENTS_C__)
 gdk_event_copy
diff --git a/gdk/gdktestutils.h b/gdk/gdktestutils.h
new file mode 100644 (file)
index 0000000..9bd5b33
--- /dev/null
@@ -0,0 +1,42 @@
+/* Gdk testing utilities
+ * Copyright (C) 2007 Tim Janik
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+#ifndef __GDK_TEST_UTILS_H__
+#define __GDK_TEST_UTILS_H__
+
+#include <gdk/gdkwindow.h>
+
+G_BEGIN_DECLS;
+
+/* --- Gdk Test Utility API --- */
+void            gdk_test_render_sync            (GdkWindow      *window);
+gboolean        gdk_test_simulate_key           (GdkWindow      *window,
+                                                 gint            x,
+                                                 gint            y,
+                                                 guint           keyval,
+                                                 GdkModifierType modifiers,
+                                                 GdkEventType    key_pressrelease);
+gboolean        gdk_test_simulate_button        (GdkWindow      *window,
+                                                 gint            x,
+                                                 gint            y,
+                                                 guint           button, /*1..3*/
+                                                 GdkModifierType modifiers,
+                                                 GdkEventType    button_pressrelease);
+G_END_DECLS;
+
+#endif /* __GDK_TEST_UTILS_H__ */
index 1730fb34bde67e7a82fc3756cc3824d1eb0fa40e..4ba5007a498759e5cf558a5c68fd668112f179cb 100644 (file)
@@ -44,6 +44,7 @@ libgdk_x11_la_SOURCES =       \
        gdkscreen-x11.h         \
        gdkselection-x11.c      \
        gdkspawn-x11.c          \
+       gdktestutils-x11.c      \
        gdkvisual-x11.c         \
        gdkwindow-x11.c         \
        gdkwindow-x11.h         \
diff --git a/gdk/x11/gdktestutils-x11.c b/gdk/x11/gdktestutils-x11.c
new file mode 100644 (file)
index 0000000..e1fdfa9
--- /dev/null
@@ -0,0 +1,218 @@
+/* Gtk+ testing utilities
+ * Copyright (C) 2007 Tim Janik
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+#include <gdk/gdktestutils.h>
+#include <gdk/gdkkeysyms.h>
+#include <x11/gdkx.h>
+#include "gdkalias.h"
+
+#include <X11/Xlib.h>
+
+/**
+ * gdk_test_render_sync
+ * @window: a mapped GdkWindow
+ *
+ * This function retrives a pixel from @window to force the windowing
+ * system to carry out any pending rendering commands.
+ * This function is intended to be used to syncronize with rendering
+ * pipelines, to benchmark windowing system rendering operations.
+ **/
+void
+gdk_test_render_sync (GdkWindow *window)
+{
+  static GdkImage *p1image = NULL;
+  /* syncronize to X drawing queue, see:
+   * http://mail.gnome.org/archives/gtk-devel-list/2006-October/msg00103.html
+   */
+  p1image = gdk_drawable_copy_to_image (window, p1image, 0, 0, 0, 0, 1, 1);
+}
+
+/**
+ * gdk_test_simulate_key
+ * @window: Gdk window to simulate a key event for.
+ * @x:      x coordinate within @window for the key event.
+ * @y:      y coordinate within @window for the key event.
+ * @keyval: A Gdk keyboard value.
+ * @modifiers: Keyboard modifiers the event is setup with.
+ * @key_pressrelease: either %GDK_KEY_PRESS or %GDK_KEY_RELEASE
+ *
+ * This function is intended to be used in Gtk+ test programs.
+ * If (@x,@y) are > (-1,-1), it will warp the mouse pointer to
+ * the given (@x,@y) corrdinates within @window and simulate a
+ * key press or release event.
+ * When the mouse pointer is warped to the target location, use
+ * of this function outside of test programs that run in their
+ * own virtual windowing system (e.g. Xvfb) is not recommended.
+ * If (@x,@y) are passed as (-1,-1), the mouse pointer will not
+ * be warped and @window origin will be used as mouse pointer
+ * location for the event.
+ * Also, gtk_test_simulate_key() is a fairly low level function,
+ * for most testing purposes, gtk_test_widget_send_key() is the
+ * right function to call which will generate a key press event
+ * followed by its accompanying key release event.
+ *
+ * Returns: wether all actions neccessary for a key event simulation were carried out successfully.
+ **/
+gboolean
+gdk_test_simulate_key (GdkWindow      *window,
+                       gint            x,
+                       gint            y,
+                       guint           keyval,
+                       GdkModifierType modifiers,
+                       GdkEventType    key_pressrelease)
+{
+  GdkScreen *screen;
+  GdkKeymapKey *keys = NULL;
+  gboolean success;
+  gint n_keys = 0;
+  XKeyEvent xev = {
+    0,  /* type */
+    0,  /* serial */
+    1,  /* send_event */
+  };
+  g_return_val_if_fail (key_pressrelease == GDK_KEY_PRESS || key_pressrelease == GDK_KEY_RELEASE, FALSE);
+  g_return_val_if_fail (window != NULL, FALSE);
+  if (!GDK_WINDOW_IS_MAPPED (window))
+    return FALSE;
+  screen = gdk_colormap_get_screen (gdk_drawable_get_colormap (window));
+  if (x < 0 && y < 0)
+    {
+      gdk_drawable_get_size (window, &x, &y);
+      x /= 2;
+      y /= 2;
+    }
+  xev.type = key_pressrelease == GDK_KEY_PRESS ? KeyPress : KeyRelease;
+  xev.display = GDK_DRAWABLE_XDISPLAY (window);
+  xev.window = GDK_WINDOW_XID (window);
+  xev.root = RootWindow (xev.display, GDK_SCREEN_XNUMBER (screen));
+  xev.subwindow = 0;
+  xev.time = 0;
+  xev.x = MAX (x, 0);
+  xev.y = MAX (y, 0);
+  xev.x_root = 0;
+  xev.y_root = 0;
+  xev.state = modifiers;
+  xev.keycode = 0;
+  success = gdk_keymap_get_entries_for_keyval (gdk_keymap_get_for_display (gdk_drawable_get_display (window)), keyval, &keys, &n_keys);
+  success &= n_keys > 0;
+  if (success)
+    {
+      gint i;
+      for (i = 0; i < n_keys; i++)
+        if (keys[i].group == 0 && keys[i].level == 0)
+          {
+            xev.keycode = keys[i].keycode;
+            break;
+          }
+      if (i >= n_keys) /* no match for group==0 and level==0 */
+        xev.keycode = keys[0].keycode;
+    }
+  g_free (keys);
+  if (!success)
+    return FALSE;
+  gdk_error_trap_push ();
+  xev.same_screen = XTranslateCoordinates (xev.display, xev.window, xev.root,
+                                           xev.x, xev.y, &xev.x_root, &xev.y_root,
+                                           &xev.subwindow);
+  if (!xev.subwindow)
+    xev.subwindow = xev.window;
+  success &= xev.same_screen;
+  if (x >= 0 && y >= 0)
+    success &= 0 != XWarpPointer (xev.display, None, xev.window, 0, 0, 0, 0, xev.x, xev.y);
+  success &= 0 != XSendEvent (xev.display, xev.window, True, key_pressrelease == GDK_KEY_PRESS ? KeyPressMask : KeyReleaseMask, (XEvent*) &xev);
+  XSync (xev.display, False);
+  success &= 0 == gdk_error_trap_pop();
+  return success;
+}
+
+/**
+ * gdk_test_simulate_button
+ * @window: Gdk window to simulate a button event for.
+ * @x:      x coordinate within @window for the button event.
+ * @y:      y coordinate within @window for the button event.
+ * @button: Number of the pointer button for the event, usually 1, 2 or 3.
+ * @modifiers: Keyboard modifiers the event is setup with.
+ * @button_pressrelease: either %GDK_BUTTON_PRESS or %GDK_BUTTON_RELEASE
+ *
+ * This function is intended to be used in Gtk+ test programs.
+ * It will warp the mouse pointer to the given (@x,@y) corrdinates
+ * within @window and simulate a button press or release event.
+ * Because the mouse pointer needs to be warped to the target
+ * location, use of this function outside of test programs that
+ * run in their own virtual windowing system (e.g. Xvfb) is not
+ * recommended.
+ * Also, gtk_test_simulate_button() is a fairly low level function,
+ * for most testing purposes, gtk_test_widget_click() is the right
+ * function to call which will generate a button press event followed
+ * by its accompanying button release event.
+ *
+ * Returns: wether all actions neccessary for a button event simulation were carried out successfully.
+ **/
+gboolean
+gdk_test_simulate_button (GdkWindow      *window,
+                          gint            x,
+                          gint            y,
+                          guint           button, /*1..3*/
+                          GdkModifierType modifiers,
+                          GdkEventType    button_pressrelease)
+{
+  GdkScreen *screen;
+  XButtonEvent xev = {
+    0,  /* type */
+    0,  /* serial */
+    1,  /* send_event */
+  };
+  g_return_val_if_fail (button_pressrelease == GDK_BUTTON_PRESS || button_pressrelease == GDK_BUTTON_RELEASE, FALSE);
+  g_return_val_if_fail (window != NULL, FALSE);
+  if (!GDK_WINDOW_IS_MAPPED (window))
+    return FALSE;
+  screen = gdk_colormap_get_screen (gdk_drawable_get_colormap (window));
+  if (x < 0 && y < 0)
+    {
+      gdk_drawable_get_size (window, &x, &y);
+      x /= 2;
+      y /= 2;
+    }
+  xev.type = button_pressrelease == GDK_BUTTON_PRESS ? ButtonPress : ButtonRelease;
+  xev.display = GDK_DRAWABLE_XDISPLAY (window);
+  xev.window = GDK_WINDOW_XID (window);
+  xev.root = RootWindow (xev.display, GDK_SCREEN_XNUMBER (screen));
+  xev.subwindow = 0;
+  xev.time = 0;
+  xev.x = x;
+  xev.y = y;
+  xev.x_root = 0;
+  xev.y_root = 0;
+  xev.state = modifiers;
+  xev.button = button;
+  gdk_error_trap_push ();
+  xev.same_screen = XTranslateCoordinates (xev.display, xev.window, xev.root,
+                                           xev.x, xev.y, &xev.x_root, &xev.y_root,
+                                           &xev.subwindow);
+  if (!xev.subwindow)
+    xev.subwindow = xev.window;
+  gboolean success = xev.same_screen;
+  success &= 0 != XWarpPointer (xev.display, None, xev.window, 0, 0, 0, 0, xev.x, xev.y);
+  success &= 0 != XSendEvent (xev.display, xev.window, True, button_pressrelease == GDK_BUTTON_PRESS ? ButtonPressMask : ButtonReleaseMask, (XEvent*) &xev);
+  XSync (xev.display, False);
+  success &= 0 == gdk_error_trap_pop();
+  return success;
+}
+
+#define __GDK_TEST_UTILS_X11_C__
+#include "gdkaliasdef.c"
index 8586151b55c91134bd30a54c6fa2f0fbb2f26952..c657cc82086e5c10c32224db9af92cfd55f499b6 100644 (file)
@@ -3263,8 +3263,6 @@ gtk_test_find_sibling
 gtk_test_find_widget
 gtk_test_init
 gtk_test_register_all_types
-gtk_test_simulate_button
-gtk_test_simulate_key
 gtk_test_slider_get_value
 gtk_test_slider_set_perc
 gtk_test_spin_button_click
@@ -3272,7 +3270,6 @@ gtk_test_text_get
 gtk_test_text_set
 gtk_test_widget_click
 gtk_test_widget_send_key
-gtk_test_xserver_render_sync
 #endif
 #endif
 
index b5daba6d28b7c6c6150445649017d9acac951305..72dd01a5281f06fb597a2a7e6c43bd9719f37a8a 100644 (file)
  */
 #include "gtktestutils.h"
 #include <gtk/gtk.h>
-#include <gdk/gdkkeysyms.h>
-#include <x11/gdkx.h>
+#include <gdk/gdktestutils.h>
 #include "gtkalias.h"
 
-#include <X11/Xlib.h>
 #include <locale.h>
 #include <string.h>
 #include <math.h>
@@ -88,99 +86,6 @@ test_find_widget_input_windows (GtkWidget *widget,
   return g_slist_reverse (matches);
 }
 
-/**
- * gtk_test_simulate_key
- * @window: Gdk window to simulate a key event for.
- * @x:      x coordinate within @window for the key event.
- * @y:      y coordinate within @window for the key event.
- * @keyval: A Gdk keyboard value.
- * @modifiers: Keyboard modifiers the event is setup with.
- * @press_or_release: %TRUE to generate key press events, %FALSE to generate key release events.
- *
- * This function is intended to be used in Gtk+ test programs.
- * If (@x,@y) are > (-1,-1), it will warp the mouse pointer to
- * the given (@x,@y) corrdinates within @window and simulate a
- * key press or release event.
- * When the mouse pointer is warped to the target location, use
- * of this function outside of test programs that run in their
- * own virtual windowing system (e.g. Xvfb) is not recommended.
- * If (@x,@y) are passed as (-1,-1), the mouse pointer will not
- * be warped and @window origin will be used as mouse pointer
- * location for the event.
- * Also, gtk_test_simulate_key() is a fairly low level function,
- * for most testing purposes, gtk_test_widget_send_key() is the
- * right function to call which will generate a key press event
- * followed by its accompanying key release event.
- *
- * Returns: wether all actions neccessary for a key event simulation were carried out successfully.
- **/
-gboolean
-gtk_test_simulate_key (GdkWindow      *window,
-                       gint            x,
-                       gint            y,
-                       guint           keyval,
-                       GdkModifierType modifiers,
-                       gboolean        press_or_release)
-{
-  GdkScreen *screen = gdk_colormap_get_screen (gdk_drawable_get_colormap (window));
-  GdkKeymapKey *keys = NULL;
-  gboolean success;
-  gint n_keys = 0;
-  XKeyEvent xev = {
-    0,  /* type */
-    0,  /* serial */
-    1,  /* send_event */
-  };
-  if (x < 0 && y < 0)
-    {
-      gdk_drawable_get_size (window, &x, &y);
-      x /= 2;
-      y /= 2;
-    }
-  xev.type = press_or_release ? KeyPress : KeyRelease;
-  xev.display = GDK_DRAWABLE_XDISPLAY (window);
-  xev.window = GDK_WINDOW_XID (window);
-  xev.root = RootWindow (xev.display, GDK_SCREEN_XNUMBER (screen));
-  xev.subwindow = 0;
-  xev.time = 0;
-  xev.x = MAX (x, 0);
-  xev.y = MAX (y, 0);
-  xev.x_root = 0;
-  xev.y_root = 0;
-  xev.state = modifiers;
-  xev.keycode = 0;
-  success = gdk_keymap_get_entries_for_keyval (gdk_keymap_get_for_display (gdk_drawable_get_display (window)), keyval, &keys, &n_keys);
-  success &= n_keys > 0;
-  if (success)
-    {
-      gint i;
-      for (i = 0; i < n_keys; i++)
-        if (keys[i].group == 0 && keys[i].level == 0)
-          {
-            xev.keycode = keys[i].keycode;
-            break;
-          }
-      if (i >= n_keys) /* no match for group==0 and level==0 */
-        xev.keycode = keys[0].keycode;
-    }
-  g_free (keys);
-  if (!success)
-    return FALSE;
-  gdk_error_trap_push ();
-  xev.same_screen = XTranslateCoordinates (xev.display, xev.window, xev.root,
-                                           xev.x, xev.y, &xev.x_root, &xev.y_root,
-                                           &xev.subwindow);
-  if (!xev.subwindow)
-    xev.subwindow = xev.window;
-  success &= xev.same_screen;
-  if (x >= 0 && y >= 0)
-    success &= 0 != XWarpPointer (xev.display, None, xev.window, 0, 0, 0, 0, xev.x, xev.y);
-  success &= 0 != XSendEvent (xev.display, xev.window, True, press_or_release ? KeyPressMask : KeyReleaseMask, (XEvent*) &xev);
-  XSync (xev.display, False);
-  success &= 0 == gdk_error_trap_pop();
-  return success;
-}
-
 /**
  * gtk_test_widget_send_key
  * @widget: Widget to generate a key press and release on.
@@ -193,7 +98,7 @@ gtk_test_simulate_key (GdkWindow      *window,
  * input-only event window. For other widgets, this is usually widget->window.
  * Certain caveats should be considered when using this function, in
  * particular because the mouse pointer is warped to the key press
- * location, see gtk_test_simulate_key() for details.
+ * location, see gdk_test_simulate_key() for details.
  *
  * Returns: wether all actions neccessary for the key event simulation were carried out successfully.
  **/
@@ -208,81 +113,12 @@ gtk_test_widget_send_key (GtkWidget      *widget,
     iwindows = test_find_widget_input_windows (widget, TRUE);
   if (!iwindows)
     return FALSE;
-  k1res = gtk_test_simulate_key (iwindows->data, -1, -1, keyval, modifiers, TRUE);
-  k2res = gtk_test_simulate_key (iwindows->data, -1, -1, keyval, modifiers, FALSE);
+  k1res = gdk_test_simulate_key (iwindows->data, -1, -1, keyval, modifiers, GDK_KEY_PRESS);
+  k2res = gdk_test_simulate_key (iwindows->data, -1, -1, keyval, modifiers, GDK_KEY_RELEASE);
   g_slist_free (iwindows);
   return k1res && k2res;
 }
 
-/**
- * gtk_test_simulate_button
- * @window: Gdk window to simulate a button event for.
- * @x:      x coordinate within @window for the button event.
- * @y:      y coordinate within @window for the button event.
- * @button: Number of the pointer button for the event, usually 1, 2 or 3.
- * @modifiers: Keyboard modifiers the event is setup with.
- * @press_or_release: %TRUE to generate button press events, %FALSE to generate button release events.
- *
- * This function is intended to be used in Gtk+ test programs.
- * It will warp the mouse pointer to the given (@x,@y) corrdinates
- * within @window and simulate a button press or release event.
- * Because the mouse pointer needs to be warped to the target
- * location, use of this function outside of test programs that
- * run in their own virtual windowing system (e.g. Xvfb) is not
- * recommended.
- * Also, gtk_test_simulate_button() is a fairly low level function,
- * for most testing purposes, gtk_test_widget_click() is the right
- * function to call which will generate a button press event followed
- * by its accompanying button release event.
- *
- * Returns: wether all actions neccessary for a button event simulation were carried out successfully.
- **/
-gboolean
-gtk_test_simulate_button (GdkWindow      *window,
-                          gint            x,
-                          gint            y,
-                          guint           button, /*1..3*/
-                          GdkModifierType modifiers,
-                          gboolean        press_or_release)
-{
-  GdkScreen *screen = gdk_colormap_get_screen (gdk_drawable_get_colormap (window));
-  XButtonEvent xev = {
-    0,  /* type */
-    0,  /* serial */
-    1,  /* send_event */
-  };
-  if (x < 0 && y < 0)
-    {
-      gdk_drawable_get_size (window, &x, &y);
-      x /= 2;
-      y /= 2;
-    }
-  xev.type = press_or_release ? ButtonPress : ButtonRelease;
-  xev.display = GDK_DRAWABLE_XDISPLAY (window);
-  xev.window = GDK_WINDOW_XID (window);
-  xev.root = RootWindow (xev.display, GDK_SCREEN_XNUMBER (screen));
-  xev.subwindow = 0;
-  xev.time = 0;
-  xev.x = x;
-  xev.y = y;
-  xev.x_root = 0;
-  xev.y_root = 0;
-  xev.state = modifiers;
-  xev.button = button;
-  gdk_error_trap_push ();
-  xev.same_screen = XTranslateCoordinates (xev.display, xev.window, xev.root,
-                                           xev.x, xev.y, &xev.x_root, &xev.y_root,
-                                           &xev.subwindow);
-  if (!xev.subwindow)
-    xev.subwindow = xev.window;
-  gboolean success = xev.same_screen;
-  success &= 0 != XWarpPointer (xev.display, None, xev.window, 0, 0, 0, 0, xev.x, xev.y);
-  success &= 0 != XSendEvent (xev.display, xev.window, True, press_or_release ? ButtonPressMask : ButtonReleaseMask, (XEvent*) &xev);
-  XSync (xev.display, False);
-  success &= 0 == gdk_error_trap_pop();
-  return success;
-}
-
 /**
  * gtk_test_widget_click
  * @widget: Widget to generate a button click on.
@@ -296,7 +132,7 @@ gtk_test_simulate_button (GdkWindow      *window,
  * input-only event window. For other widgets, this is usually widget->window.
  * Certain caveats should be considered when using this function, in
  * particular because the mouse pointer is warped to the button click
- * location, see gtk_test_simulate_button() for details.
+ * location, see gdk_test_simulate_button() for details.
  *
  * Returns: wether all actions neccessary for the button click simulation were carried out successfully.
  **/
@@ -311,8 +147,8 @@ gtk_test_widget_click (GtkWidget      *widget,
     iwindows = test_find_widget_input_windows (widget, TRUE);
   if (!iwindows)
     return FALSE;
-  b1res = gtk_test_simulate_button (iwindows->data, -1, -1, button, modifiers, TRUE);
-  b2res = gtk_test_simulate_button (iwindows->data, -1, -1, button, modifiers, FALSE);
+  b1res = gdk_test_simulate_button (iwindows->data, -1, -1, button, modifiers, GDK_BUTTON_PRESS);
+  b2res = gdk_test_simulate_button (iwindows->data, -1, -1, button, modifiers, GDK_BUTTON_RELEASE);
   g_slist_free (iwindows);
   return b1res && b2res;
 }
@@ -340,8 +176,8 @@ gtk_test_spin_button_click (GtkSpinButton  *spinner,
       gint width, height, pos;
       gdk_drawable_get_size (spinner->panel, &width, &height);
       pos = upwards ? 0 : height - 1;
-      b1res = gtk_test_simulate_button (spinner->panel, width - 1, pos, button, 0, TRUE);
-      b2res = gtk_test_simulate_button (spinner->panel, width - 1, pos, button, 0, FALSE);
+      b1res = gdk_test_simulate_button (spinner->panel, width - 1, pos, button, 0, GDK_BUTTON_PRESS);
+      b2res = gdk_test_simulate_button (spinner->panel, width - 1, pos, button, 0, GDK_BUTTON_RELEASE);
     }
   return b1res && b2res;
 }
@@ -732,25 +568,6 @@ gtk_test_create_simple_window (const gchar *window_title,
   return window;
 }
 
-/**
- * gtk_test_xserver_render_sync
- * @window: a mapped GdkWindow
- *
- * This function retrives a pixel from @window to force the windowing
- * system to carry out any pending rendering commands.
- * This function is intended to be used to syncronize with rendering
- * pipelines, to benchmark windowing system rendering operations.
- **/
-void
-gtk_test_xserver_render_sync (GdkWindow *window)
-{
-  static GdkImage *p1image = NULL;
-  /* syncronize to X drawing queue, see:
-   * http://mail.gnome.org/archives/gtk-devel-list/2006-October/msg00103.html
-   */
-  p1image = gdk_drawable_copy_to_image (window, p1image, 0, 0, 0, 0, 1, 1);
-}
-
 /**
  * gtk_test_register_all_types
  *
index 3550ae949d80a9c3e9c78ace854f2719c438b27e..18781fea6566d8c3136aba400abde4b94211b922 100644 (file)
@@ -40,7 +40,6 @@ GtkWidget*      gtk_test_create_simple_window   (const gchar    *window_title,
 GtkWidget*      gtk_test_display_button_window  (const gchar    *window_title,
                                                  const gchar    *dialog_text,
                                                  ...); /* NULL terminated list of (label, &int) pairs */
-void            gtk_test_xserver_render_sync    (GdkWindow      *window);
 void            gtk_test_slider_set_perc        (GtkWidget      *widget, /* GtkRange-alike */
                                                  double          percentage);
 double          gtk_test_slider_get_value       (GtkWidget      *widget);
@@ -63,18 +62,6 @@ GtkWidget*      gtk_test_find_sibling           (GtkWidget      *base_widget,
                                                  GType           widget_type);
 GtkWidget*      gtk_test_find_label             (GtkWidget      *widget,
                                                  const gchar    *label_pattern);
-gboolean        gtk_test_simulate_key           (GdkWindow      *window,
-                                                 gint            x,
-                                                 gint            y,
-                                                 guint           keyval,
-                                                 GdkModifierType modifiers,
-                                                 gboolean        press_or_release);
-gboolean        gtk_test_simulate_button        (GdkWindow      *window,
-                                                 gint            x,
-                                                 gint            y,
-                                                 guint           button, /*1..3*/
-                                                 GdkModifierType modifiers,
-                                                 gboolean        press_or_release);
 G_END_DECLS;
 
 #endif /* __GTK_TEST_UTILS_H__ */
index 202b6f7fb6a8c9d817e056211bee193574dfccb4..516597050c96f3162ce1af154200baffc128fcd2 100644 (file)
@@ -157,7 +157,7 @@ test_xserver_sync (void)
         {
           gdk_draw_line (darea->window, darea->style->black_gc, 0, 0, 320, 200);
           gdk_draw_line (darea->window, darea->style->black_gc, 320, 0, 0, 200);
-          gtk_test_xserver_render_sync (darea->window);
+          gdk_test_render_sync (darea->window);
         }
       g_timer_stop (gtimer);
       sync_time = g_timer_elapsed (gtimer, NULL);